using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using DevExpress.Utils;
using DevExpress.XtraNavBar.ViewInfo;
using DevExpress.XtraNavBar;

namespace AnsweringSystem
{
    public class BaseButton : PictureBox
    {
        public event EventHandler ButtonClick;
        internal ImageCollection images = null;
        public int btnType = 1;
        public BaseButton()
        {
            this.BackColor = Color.Transparent;
            this.SizeMode = PictureBoxSizeMode.AutoSize;
            ImageCollection images = new ImageCollection();
            images.ImageSize = new Size(34, 18);
            images.TransparentColor = Color.Transparent;
            if (btnType == 1)
            {
                images.AddImageStrip((Image)Properties.Resources.minimize_buttons);
            }
            else if (btnType == 2)
            {
                images.AddImageStrip((Image)Properties.Resources.close_buttons);
            }
            this.Image = images.Images[0];
        }

        protected virtual void CreateImages()
        {
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Image Image
        {
            get { return base.Image; }
            set { base.Image = value; }
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            this.Image = images.Images[1];
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            this.Image = images.Images[0];
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button != MouseButtons.Left) return;
            this.Image = images.Images[2];
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button != MouseButtons.Left) return;
            if (new Rectangle(0, 0, this.Width, this.Height).Contains(new Point(e.X, e.Y)))
            {
                this.Image = images.Images[1];
                RaiseButtonClick();
            }
            else
            {
                this.Image = images.Images[0];
            }
        }

        private void RaiseButtonClick()
        {
            if (ButtonClick != null)
                ButtonClick(this, EventArgs.Empty);
        }
    }

    public class CloseButton:PictureBox
    {
        public event EventHandler ButtonClick;
        internal ImageCollection images = null;
        public CloseButton()
        {
            this.BackColor = Color.Transparent;
            this.SizeMode = PictureBoxSizeMode.AutoSize;
            Image image = Image.FromFile(@"F:\WiseStar\answering-system\trunk\AnsweringSystem\AnsweringSystem\close_buttons.png");
            ImageCollection images = new ImageCollection();
            images.ImageSize = new Size(34, 18);
            images.TransparentColor = Color.Transparent;
            //images.AddImageStrip((Image)Properties.Resources.close_buttons);
            images.AddImageStrip(image);


            this.Image = images.Images[0];
        }

        protected virtual void CreateImages()
        {
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Image Image
        {
            get { return base.Image; }
            set { base.Image = value; }
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            this.Image = images.Images[1];
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            this.Image = images.Images[0];
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button != MouseButtons.Left) return;
            this.Image = images.Images[2];
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button != MouseButtons.Left) return;
            if (new Rectangle(0, 0, this.Width, this.Height).Contains(new Point(e.X, e.Y)))
            {
                this.Image = images.Images[1];
                RaiseButtonClick();
            }
            else
            {
                this.Image = images.Images[0];
            }
        }

        private void RaiseButtonClick()
        {
            if (ButtonClick != null)
                ButtonClick(this, EventArgs.Empty);
        }
    }

     public class MinimizeButton:PictureBox
    {
        public event EventHandler ButtonClick;
        internal ImageCollection images = null;
        public MinimizeButton()
        {
            this.BackColor = Color.Transparent;
            this.SizeMode = PictureBoxSizeMode.AutoSize;
            Image image = Image.FromFile(@"F:\WiseStar\answering-system\trunk\AnsweringSystem\AnsweringSystem\minimize_buttons.png");
            ImageCollection images = new ImageCollection();
            images.ImageSize = new Size(34, 18);
            images.TransparentColor = Color.Transparent;
         //   images.AddImageStrip((Image)Properties.Resources.minimize_buttons);
            images.AddImageStrip(image);
            this.Image = images.Images[0];
        }

        protected virtual void CreateImages()
        {
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Image Image
        {
            get { return base.Image; }
            set { base.Image = value; }
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            this.Image = images.Images[1];
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            this.Image = images.Images[0];
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button != MouseButtons.Left) return;
            this.Image = images.Images[2];
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button != MouseButtons.Left) return;
            if (new Rectangle(0, 0, this.Width, this.Height).Contains(new Point(e.X, e.Y)))
            {
                this.Image = images.Images[1];
                RaiseButtonClick();
            }
            else
            {
                this.Image = images.Images[0];
            }
        }

        private void RaiseButtonClick()
        {
            if (ButtonClick != null)
                ButtonClick(this, EventArgs.Empty);
        }
    }

	public class CustomNavLinkPainter : Office2NavLinkPainter {
		public CustomNavLinkPainter(NavBarControl navBar)
			: base(navBar) {
		}
		protected override void DrawLinkImageBorder(DevExpress.Utils.Drawing.ObjectInfoArgs e, Rectangle r) {
		}
	}
	public class CustomViewInfoRegistrator : Office2ViewInfoRegistrator {
		public override string ViewName {
			get {
				return "CustomView";
			}
		}
		public override BaseNavLinkPainter CreateLinkPainter(NavBarControl navBar) {
			return new CustomNavLinkPainter(navBar);
		}
	}


  

	
}
